#ifndef CNETWORKDATA_H
#define CNETWORKDATA_H

#include <QObject>
#include <QTimer>
#include <QTime>
#include <QTcpSocket>
#include <QReadWriteLock>

//本类用来处理网络数据的收发
class CNetworkData
{
public:
    explicit CNetworkData();
    int _length,_id;
    QByteArray _d;
};

class CSyncNetwork : public QTcpSocket
{
    Q_OBJECT
public:
    explicit CSyncNetwork(QTcpSocket *parent = 0);
    void readyToWork();

    bool sendPackData(QByteArray &data);
    bool sendPackDataAppend2Sharp(QByteArray &data);
    void packageData(QByteArray data);
    void setOnceDataMode(bool on);

signals:
    void s_onceData(QByteArray);

protected slots:
    bool writeNetData(QByteArray &data);
    void readNetData();

private:

    QByteArray _magicHeader,_magicAckHeader;
    CNetworkData _sendData,_rcvData;
    QIODevice *_io_s;
    bool _onceMode;
};



#endif // CNETWORKDATA_H
